package com.xueyi.aixihu.pattern;

import com.xueyi.aixihu.constant.SystemRoleConstant;

/**
 * 描述 校验财务报表操作角色 策略接口
 *
 * @author 刘梓江
 */
public interface CheckOperationReportRoleStrategy {

    //查询审核内容角色校验
    default boolean auditSelect(Integer roleId){return false;}

    //查询自己内容角色校验
    default boolean commonSelect(Integer roleId){return false;}

    //编辑（增加、修改、删除）角色校验
    default boolean edit(Integer roleId){return false;}

    //报表提交角色校验
    default boolean submit(Integer roleId) {
        return false;
    }

    //报表一级审核角色校验
    default boolean oneLevelAudit(Integer roleId) {
        return false;
    }

    //报表二级审核角色校验
    default boolean twoLevelAudit(Integer roleId) {
        return false;
    }

    //报表发布角色校验
    default boolean release(Integer roleId) {
        return false;
    }
}

//镇财务报表操作角色
class TownCheckOperationReportRoleStrategy implements CheckOperationReportRoleStrategy {

    private TownCheckOperationReportRoleStrategy() {
    }

    private static final TownCheckOperationReportRoleStrategy instance = new TownCheckOperationReportRoleStrategy();

    public static TownCheckOperationReportRoleStrategy getInstance() {
        return instance;
    }

    public boolean auditSelect(Integer roleId){
        if(SystemRoleConstant.Z_CZS_SZ.equals(roleId)){
            return true;
        }
        return false;
    }
    public boolean commonSelect(Integer roleId){
        if(SystemRoleConstant.Z_CZS_CY.equals(roleId)||SystemRoleConstant.Z_CZS_SZ.equals(roleId)){
            return true;
        }
        return false;
    }
    public boolean edit(Integer roleId){
        if(SystemRoleConstant.Z_CZS_CY.equals(roleId)){
            return true;
        }
        return false;
    }
    public boolean submit(Integer roleId) {
        if (roleId.equals(SystemRoleConstant.Z_CZS_CY)) {
            //当前角色是财政所成员
            return true;
        }
        return false;
    }
    public boolean oneLevelAudit(Integer roleId) {
        if (roleId.equals(SystemRoleConstant.Z_CZS_SZ)) {
            //当前角色是财政所所长
            return true;
        }
        return false;
    }
    public boolean release(Integer roleId) {
        if (roleId.equals(SystemRoleConstant.Z_CZS_SZ)) {
            //当前角色是财政所所长
            return true;
        }
        return false;
    }

}

//村财务报表操作角色
class VillageCheckOperationReportRoleStrategy implements CheckOperationReportRoleStrategy {

    private VillageCheckOperationReportRoleStrategy() {
    }

    private static final VillageCheckOperationReportRoleStrategy instance = new VillageCheckOperationReportRoleStrategy();

    public static VillageCheckOperationReportRoleStrategy getInstance() {
        return instance;
    }

    public boolean auditSelect(Integer roleId){
        if(SystemRoleConstant.Z_JGZ_CY.equals(roleId)||SystemRoleConstant.Z_JGZ_ZZ.equals(roleId)){
            return true;
        }
        return false;
    }
    public boolean commonSelect(Integer roleId){
        if(SystemRoleConstant.CUN.equals(roleId)){
            return true;
        }
        return false;
    }
    public boolean edit(Integer roleId){
        if(SystemRoleConstant.CUN.equals(roleId)){
            return true;
        }
        return false;
    }
    public boolean submit(Integer roleId) {
        if (roleId.equals(SystemRoleConstant.CUN)) {
            //当前角色是村
            return true;
        }
        return false;
    }
    public boolean oneLevelAudit(Integer roleId) {
        if (roleId.equals(SystemRoleConstant.Z_JGZ_CY)) {
            //当前角色是经管站成员
            return true;
        }
        return false;
    }
    public boolean twoLevelAudit(Integer roleId) {
        if (roleId.equals(SystemRoleConstant.Z_JGZ_ZZ)) {
            //当前角色是经管站站长
            return true;
        }
        return false;
    }
    public boolean release(Integer roleId) {
        if (roleId.equals(SystemRoleConstant.CUN)) {
            //当前角色是村
            return true;
        }
        return false;
    }

}

//社区/居委会财务报表操作角色
class CommunityCheckOperationReportRoleStrategy implements CheckOperationReportRoleStrategy {

    private CommunityCheckOperationReportRoleStrategy() {
    }

    private static final CommunityCheckOperationReportRoleStrategy instance = new CommunityCheckOperationReportRoleStrategy();

    public static CommunityCheckOperationReportRoleStrategy getInstance() {
        return instance;
    }

    public boolean auditSelect(Integer roleId){
        if(SystemRoleConstant.Z_CZS_CY.equals(roleId)||SystemRoleConstant.Z_CZS_SZ.equals(roleId)){
            return true;
        }
        return false;
    }
    public boolean commonSelect(Integer roleId){
        if(SystemRoleConstant.SQ.equals(roleId)||SystemRoleConstant.JU_WEI.equals(roleId)){
            return true;
        }
        return false;
    }
    public boolean edit(Integer roleId){
        if(SystemRoleConstant.SQ.equals(roleId)||SystemRoleConstant.JU_WEI.equals(roleId)){
            return true;
        }
        return false;
    }
    public boolean submit(Integer roleId) {
        if (roleId.equals(SystemRoleConstant.SQ) || roleId.equals(SystemRoleConstant.JU_WEI)) {
            //当前角色是村/居委
            return true;
        }
        return false;
    }
    public boolean oneLevelAudit(Integer roleId) {
        if (roleId.equals(SystemRoleConstant.Z_CZS_CY)) {
            //当前角色是财政所成员
            return true;
        }
        return false;
    }
    public boolean twoLevelAudit(Integer roleId) {
        if (roleId.equals(SystemRoleConstant.Z_CZS_SZ)) {
            //当前角色是财政所所长
            return true;
        }
        return false;
    }
    public boolean release(Integer roleId) {
        if (roleId.equals(SystemRoleConstant.SQ) || roleId.equals(SystemRoleConstant.JU_WEI)) {
            //当前角色社区/居委
            return true;
        }
        return false;
    }

}